package Meituan;

/**
 * @author: leiwenkang02@meituan.com
 * @date: 2018/8/14
 * @time: 19:27
 */
public class Test21 {
    public static void main(String[] args) {
        String str = "abcdefgh";
        String str2 = "fedc";
        //请将cdef反转

        int num1 = str.indexOf('c');        //2
        int num2 = str.lastIndexOf('f');    //5

        String str3 = "";
        for (int i = num2; i >= num1; i--) {
            str3 += str.charAt(i);
        }
        for (int i = num1; i <= num2; i++) {

            str = str.replace(str.charAt(i), str3.charAt(i - 2));

        }
        System.out.println(str3);
        System.out.println(str);


    }
}
